﻿Public Class UC_QuanLyBanAn
    Dim b As New DTOBanAn
    Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        If txtTebban.Text = "" Then
            MsgBox("Bạn nhập dữ liệu bị trống")
            Return
        Else
            b.TenBan = txtTebban.Text
            BUSBanAn.BanAn_Insert(b)
            Loadgv()
        End If
    End Sub

    Private Sub btnEdit_Click(sender As Object, e As EventArgs) Handles btnEdit.Click
        If txtTebban.Text = "" Then
            MsgBox("Bạn nhập dữ liệu bị trống")
            Return
        Else
            b.TenBan = txtTebban.Text
            b.MaTT = 1
            b.MaBan=gvBanAn.CurrentRow.Cells("MaBan").Value
            BUSBanAn.BanAn_Update(b)
            Loadgv()
        End If
    End Sub

    Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
        b.MaBan = gvBanAn.CurrentRow.Cells("MaBan").Value
        BUSBanAn.BanAn_Delete(b)
        Loadgv()
    End Sub
    Sub Loadgv()
        gvBanAn.DataSource = BUSBanAn.BanAn_Load
    End Sub
    Private Sub UC_QuanLyBanAn_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Loadgv
    End Sub
End Class
